<template>
  <el-config-provider :locale="language">
    <RouterView />
  </el-config-provider>
</template>

<script setup lang="ts">
import { RouterView } from 'vue-router'
import { computed } from 'vue'
import zhCN from 'element-plus/es/locale/lang/zh-cn'
import en from 'element-plus/es/locale/lang/en'
import { useThemeStore } from '@/store/modules/theme'
import { storage } from '@/utils/storage'
import { useAppStore } from '@/store'

const appStore = useAppStore()
// const themeStore = useThemeStore()
const language = computed(() => (appStore.language === 'zh-CN' ? zhCN : en))

const themeStore = useThemeStore()
const setDefaultTheme = () => {
  themeStore.setMenuMode(themeStore.menuMode)

  const themeSetting = storage.get('themeSetting')

  if (themeSetting?.isDark) {
    themeStore.setIsDark(true)
  }

  if (themeSetting?.themeColor) {
    themeStore.setThemeColor(themeSetting?.themeColor)
  }
}
setDefaultTheme()
</script>

<style scoped lang="scss"></style>
